<html>
<head>
<title>比赛数据采集</title>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body{font-size:12px;}
td{font-size:12px;}
</style>
</head>
<!--
<form action="#">
	<input type="text" name="date">
	<input type="submit" value="查询">
</form>
-->
<?php

date_default_timezone_set("Asia/Shanghai");

$date = @$_GET["date"];
if ($date == "") {
	$date = date("Y-m-d");
}else{
	$date = date("Y-m-d",strtotime($date." day"));
}

//连接数据库
$config = require 'conf/config.ini.php';      //加载公用config.ini.php
$conn = mysql_connect($config["DB_HOST"], $config["DB_USER"], $config["DB_PWD"]);
mysql_select_db($config["DB_NAME"], $conn);

$sql = "select * from live_match where matchTime like '" . $date . "%' and matchStatus = '直播中' and matchRecord = '直播间' order by matchTime desc";
mysql_query("SET NAMES utf8");
$matchList = mysql_query($sql, $conn);

if (mysql_num_rows($matchList) > 0) {
	while ($match = mysql_fetch_object($matchList)) {
		$basketballType = "";

		//比分抓取
		echo '<div style="float:left;width:100%;">';
		echo '<div style="width:100%;"><strong>(' . $match->matchId . ')' . $match->homeTeam . ' VS ' . $match->visitTeam . '</strong></div>';
		echo '<iframe width="100%" height="100px" frameborder="0" src="';
		if($match->matchEvent == "Y"){
			echo 'get_sports_event';
			echo '.php?matchId=' . $match->matchId . '"></iframe>';
		}else if ($match->matchCategory == "1") {
			//篮球
			if (strpos($match->matchName, "NBA")) {
				$basketballType = "NBA";
				if ($match->matchEazy == "1") {
					echo 'get_basketball_score_n';
				} else {
					echo 'get_basketball_score';
				}
			} else {
				echo 'get_basketball_score';
			}
			echo '.php?matchId=' . $match->matchId . '&type=' . $basketballType . '"></iframe>';
			echo '<iframe width="49%" height="20px" frameborder="0" src="get_basketball_team_stats.php?matchId=' . $match->matchId . '&type=' . $basketballType . '&date=' . $date . '"></iframe>';
			echo '<iframe width="49%" height="20px" frameborder="0" src="get_basketball_member_stats.php?matchId=' . $match->matchId . '&type=' . $basketballType . '&date=' . $date . '"></iframe>';
		} else if ($match->matchCategory == "2") {
			//国际足球
			echo 'get_football_score.php?matchOptaId=' . $match->matchOptaId . '&matchId=' . $match->matchId . '&type=' . $basketballType . '"></iframe>';
			echo '<iframe width="33%" height="20px" frameborder="0" src="get_football_team_stats.php?matchId=' . $match->matchId . '&matchCategory=' . $match->matchCategory . '&date=' . $date . '"></iframe>';
			echo '<iframe width="33%" height="20px" frameborder="0" src="get_football_member_stats.php?matchId=' . $match->matchId . '&matchOptaId=' . $match->matchOptaId . '&matchCategory=' . $match->matchCategory . '&matchOptaSeason=' . $match->matchOptaSeason . '&matchOptaRound=' . $match->matchOptaRound . '&date=' . $date . '"></iframe>';
			echo '<iframe width="33%" height="20px" frameborder="0" src="get_football_video.php?matchId=' . $match->matchId . '&matchTime=' . $match->matchTime . '&homeTeam=' . $match->homeTeam . '&visitTeam=' . $match->visitTeam . '&matchCategory=' . $match->matchCategory . '"></iframe>';
		} else if ($match->matchCategory == "3") {
			//国内足球
			echo 'get_football_score.php?matchId=' . $match->matchId . '&type=' . $basketballType . '"></iframe>';	
			echo '<iframe width="49%" height="20px" frameborder="0" src="get_football_member_stats.php?matchId=' . $match->matchId . '&matchOptaId=' . $match->matchOptaId . '&matchCategory=' . $match->matchCategory . '&matchOptaSeason=' . $match->matchOptaSeason . '&matchOptaRound=' . $match->matchOptaRound . '&date=' . $date . '"></iframe>';
			echo '<iframe width="49%" height="20px" frameborder="0" src="get_football_video.php?matchId=' . $match->matchId . '&matchTime=' . $match->matchTime . '&homeTeam=' . $match->homeTeam . '&visitTeam=' . $match->visitTeam . '&matchCategory=' . $match->matchCategory . '"></iframe>';
		} else if ($match->matchCategory == "4") {
			//排球
			//if (strpos($match->matchUrl, "/o/")) {
			echo 'get_volleyball_score';
			echo '.php?matchId=' . $match->matchId . '&type=' . $basketballType . '"></iframe>';
			//}
		} else if ($match->matchCategory == "5") {
			//台球
			echo 'get_billiards_score';
			echo '.php?matchId=' . $match->matchId . '&type=' . $basketballType . '"></iframe>';
		}else if ($match->matchCategory == "6") {
			//网球
			echo 'get_tennis_score';
			echo '.php?matchId=' . $match->matchId . '&type=' . $basketballType . '"></iframe>';
		}
		echo '<div align="right" style="width:100%;"><strong>' . $match->matchTime . ' -- ' . $match->matchName . '</strong></div>';
		echo "</div>";
	}
}else{
	echo '<div align="center">现在时间：'. date("Y-m-d H:i") .'<br>暂无直播中的比赛</div>';	
}
?>
</html>